<template>
  <div>
    <el-container>
      <el-main>
        <!-- 歌单介绍 -->
        <div class="m-info">
          <div class="left">
            <img v-lazy="pldetail.coverImgUrl">
            <span></span>
          </div>
          <div class="right">
            <div class="hd flex">
              <i class="iconfont icon-biaoqian"></i>
              <h2 class="tit">{{pldetail.name}}</h2>
            </div>
            <div class="user flex">
              <a
                href="#"
                class="face"
              >
                <img
                  v-lazy="pldetail.creator.avatarUrl"
                  class="facepic"
                  @click="goUserHome(pldetail.creator.userId)"
                >
              </a>
              <span
                class="name"
                @click="goUserHome(pldetail.creator.userId)"
              >
                <a href="javascript:;">{{pldetail.creator.nickname}}</a>
              </span>
              <img
                src="../../assets/image/renzheng.png"
                class="renz"
              >
              <span class="time">{{pldetail.createTime | dateFormat}}&nbsp;创建</span>
            </div>
            <div class="btns">
              <a
                href="#"
                class="bo"
              ><i class="iconfont icon-bofang"></i>播放</a>
              <a
                href="#"
                class="jia"
              ><i class="iconfont icon-hao"></i></a>
              <a href="#" @click.prevent="collectPlaylist"><i class="iconfont icon-tianjiawenjianjia"></i>({{pldetail.subscribedCount}})</a>
              <a href="#"><i class="iconfont icon-fenxiang"></i>{{pldetail.shareCount}}</a>
              <a href="#"><i class="iconfont icon-xiazai1"></i>下载</a>
              <a href="#"><i class="iconfont icon-pinglun"></i>{{pldetail.commentCount}}</a>
            </div>
            <div class="tags">
              <b>标签：</b>
              <a
                href="#"
                class="u-tag"
                v-for="(item,index) in pldetail.tags"
                :key="index"
              ><i>{{item}}</i></a>
            </div>
            <p class="intr">介绍：{{pldetail.description}}</p>
          </div>
        </div>
        <!-- END------------------------------ -->
        <!-- 歌单内容 -->
        <div class="n-songtb">
          <div class="utit">
            <span class="songlist">歌曲列表</span>
            <span class="songnum">{{pldetail.trackCount}}首歌</span>
            <div class="bf">播放<span>{{pldetail.playCount}}</span>次</div>
            <a href="#">
              <i class="iconfont icon-yinfu"></i>
              <span>生成外链播放器</span>
            </a>
          </div>
          <div class="songlis">
            <table class="mtable">
              <thead>
                <tr>
                  <th class="first"></th>
                  <th class="biao">歌曲标题</th>
                  <th class="time">时长</th>
                  <th class="artister">歌手</th>
                  <th class="zhuanji">专辑</th>
                </tr>
              </thead>
              <tbody>
                <tr
                  v-for="(item,index) in pldetail.tracks"
                  :key="index"
                >
                  <td class="one">
                    <div class="hd">
                      <span class="num">{{index+1}}</span>
                      <i
                        class="iconfont icon-bofang"
                        @click="playMusic(item.id)"
                      ></i>
                    </div>
                  </td>
                  <td class="music flex">
                    <a
                      href="#"
                      class="f-thide"
                      @click.prevent="goSong(item.id)"
                    >{{item.name}}</a>
                  </td>
                  <td class="timelong">
                    <span>{{item.dt | dateFormat2}}</span>
                    <div class="td iconfa">
                      <div class="boxaaa icons">
                        <a
                          href="#"
                          class="icn"
                        ><i class="iconfont icon-hao"></i></a>
                        <a
                          href="javascript:;"
                          class="icn"
                          
                        ><i class="iconfont icon-tianjiawenjianjia"></i></a>
                        <a
                          href="#"
                          class="icn"
                        ><i class="iconfont icon-fenxiang"></i></a>
                        <a
                          href="#"
                          class="icn"
                        ><i class="iconfont icon-xiazai1"></i></a>
                      </div>

                    </div>
                  </td>
                  <!-- 歌手 -->
                  <td
                    class="artister f-thide"
                    @click.prevent="goArtist(item.ar[0].id)"
                  >{{item.ar[0].name}}</td>
                  <!-- 专辑 -->
                  <td
                    class="zhuan f-thide"
                    @click.prevent="goAlbum(item.al.id)"
                  >{{item.al.name}}</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
        <div class="m-playlist-see-more">
          <div class="text">查看更多内容，请下载客户端</div>
          <a
            href="#"
            class="nowdow"
          >立即下载</a>
        </div>
        <!-- END------------------------------ -->
        <!-- 评论区 -->
        <commo :pid="plid"></commo>
        <!-- END------------------------------ -->
      </el-main>
      <el-aside width="270px">
        <p class="famil">喜欢这个歌单的人</p>
        <ul class="likeper">
          <li
            v-for="(item,index) in simlist"
            :key="index"
          >
            <img
              v-lazy="item.avatarUrl"
              @click="goUserHome(item.userId)"
            >
          </li>
        </ul>
        <p class="famil">热门歌单</p>
        <ul class="hotots">
          <li
            v-for="(item,index4) in hotlist"
            :key="index4"
            class="flex"
          >
            <div class="left">
              <img v-lazy="item.coverImgUrl">
            </div>
            <div class="right">
              <p class="fir f-thide"><a
                  href="#"
                  @click.prevent="gopldetail(item.id)"
                >{{item.name}}</a></p>
              <p class="sec f-thide">by<a href="#">{{item.userId}}</a></p>
            </div>
          </li>
        </ul>
        <div class="moreInsl">
          <p class="duoduan">网易云音乐多端下载</p>
          <ul>
            <li class="fir">
              <a href="#">
                <i class="iconfont icon-anzhuoshouji"></i>
              </a>
            </li>
            <li class="sec">
              <a href="#">
                <i class="iconfont icon-windows"></i>
              </a>
            </li>
            <li class="thr">
              <a href="#">
                <i class="iconfont icon-pingguoshouji"></i>
              </a>
            </li>
          </ul>
          <p class="last">同步歌单，随时畅听320k好音乐</p>
        </div>
      </el-aside>
    </el-container>
  </div>

</template>

<script>
import axios from 'axios'
import commo from '../comment/comment'
import bus from '../../eventbus'
import { mapMutations } from 'vuex'
export default {
  components: { commo },
  data () {
    return {
      plid: 0,
      pldetail: [
        {
          creator: {
            avatarUrl: '',
            nickname: ''
          },
          tracks: '',
          playCount: 0,
          trackCount: 0,
          description: ''
        }
      ],
      // 喜欢歌单的用户
      simlist: [
        { avatarUrl: '' }
      ],
      // 热门歌单
      hotlist: [],
    }
  },
  created () {
    this.getplDetail()
    this.getsimlist()
    this.gethotlist()
  },
  watch: {
    plid (newVal, oldVal) {
      console.log(newVal, oldVal)
    }
  },
  methods: {
    ...mapMutations(['goSong']),
    // 点击收藏按钮——收藏歌单
    async collectPlaylist () {
      let res = await axios.get('https://autumnfish.cn//playlist/subscribe?t=1&id='+ this.plid)
      console.log(res)
    },
    // 获取歌单内容
    async getplDetail () {
      this.plid = this.$route.query.id
      let res = await axios.get('https://autumnfish.cn//playlist/detail?id=' + this.plid)
      this.pldetail = res.data.playlist
      // console.log(this.pldetail)
    },
    // 获取喜欢这个歌单的人
    async getsimlist () {
      let res = await axios.get('https://autumnfish.cn//playlist/subscribers?id=' + this.plid + '&limit=8')
      this.simlist = res.data.subscribers
      // console.log(this.simlist)
    },
    async gethotlist () {
      let res = await axios.get('https://autumnfish.cn//top/playlist?limit=5')
      this.hotlist = res.data.playlists
      // console.log(this.hotlist)
    },
    goUserHome (id) {
      // console.log('----------------', id)
      this.$router.push({ path: '/user', query: { id: id } })
    },
    // 点击作者，跳转至个人页
    goArtist (id) {
      this.$router.push({ path: '/artist', query: { id: id } })
    },
    // 点击专辑名，跳转至专辑
    goAlbum (id) {
      this.$router.push({ path: '/discover/album', query: { id: id } })
    },
    gopldetail (id) {
      this.$router.push({ path: '/playlist', query: { id: id } })
      // ------------------待优化。自己跳自己
      this.getplDetail()
      this.getsimlist()
      this.gethotlist()
    },
    // 点击播放按钮，播放音乐
    playMusic (id) {
      bus.$emit('musicid', id)
    }
  }
}
</script>

<style lang="less" scoped>
.el-container {
  width: 980px;
  min-height: 700px;
  _height: 700px;
  margin: 0 auto;
  background-color: #fff;
  border: 1px solid #d3d3d3;
  border-width: 0 1px;
  .el-main {
    padding: 47px 30px 40px 39px !important;
    // 歌单介绍
    .m-info {
      position: relative;
      .left {
        width: 200px;
        height: 200px;
        position: absolute;
        left: 0;
        top: 0;
        img {
          width: 100%;
          height: 100%;
        }
        span {
          width: 208px;
          height: 208px;
          background-image: url(../../assets/image/coverall.png);
          background-position: 0 -1285px;
          position: absolute;
          top: -4px;
          left: -4px;
        }
      }
      .right {
        margin-left: 230px;
        .hd {
          margin: 0 0 12px;
          line-height: 24px;
          .iconfont {
            color: #da1e1e;
            font-size: 20px;
          }

          .tit {
            font-weight: normal;
            font-size: 20px;
            margin-left: 10px;
          }
        }
        .user {
          margin: 0 0 20px;
          line-height: 35px;
          .face {
            display: inline-block;
            width: 35px;
            height: 35px;
            margin-right: 10px;
            .facepic {
              width: 100%;
              height: 100%;
            }
          }
          .name {
            font-size: 12px;
            a {
              color: #0c73c2;
            }
          }
          .renz {
            height: 13px;
            width: 13px;
            display: inline-block;
            vertical-align: middle;
          }
          .time {
            font-size: 12px;
            margin-left: 15px;
            color: #999;
          }
        }
        .btns {
          margin-bottom: 25px;
          margin-right: -10px;
          a {
            color: #333;
            display: inline-block;
            margin-right: 6px;
            padding: 0 5px;
            height: 31px;
            line-height: 30px;
            min-width: 23px;
            border: 1px solid #f2f2f2;
            background-color: #f2f2f2;
            border-radius: 5px;
            font-size: 12px;
            text-align: center;
            .iconfont {
              font-size: 13px;
              margin-right: 5px;
            }
          }
          .bo {
            color: #fff;
            background-color: #4190d9;
            border: none;
            border-radius: 5px 0 0 5px;
            border-right: 1px solid #666;
          }
          .jia {
            color: #fff;
            background-color: #4190d9;
            border-radius: 0 5px 5px 0;
            border: none;
          }
        }
        .tags {
          margin: 25px 0 5px;
          line-height: 22px;
          b {
            font-weight: normal;
            color: #666;
            font-size: 12px;
          }
          .u-tag {
            display: inline-block;
            margin: 0px 10px 3px 0;
            text-shadow: 0 1px #fdfdfd;
            height: 22px;
            line-height: 22px;
            color: #333;
            border: 1px solid #000;
            background: #f4f4f4;
            border-radius: 12px;
            i {
              padding: 0 13px;
              font-style: normal;
              font-size: 12px;
            }
          }
        }
        .intr {
          margin-top: 4px;
          line-height: 18px;
          color: #666;
          font-size: 12px;
        }
      }
    }
    // 歌单内容
    .n-songtb {
      .utit {
        height: 33px;
        border-bottom: 2px solid #c20c0c;
        .songlist {
          font-size: 20px;
          float: left;
        }
        .songnum {
          font-size: 12px;
          color: #666;
          margin: 9px 0 0 20px;
          float: left;
        }
        a {
          color: #4996d1;
          font-size: 12px;
          float: right;
          margin-right: 20px;
          margin-top: 5px;
        }
        .bf {
          float: right;
          margin-top: 5px;
          font-size: 12px;
          span {
            color: #c20c0c;
          }
        }
      }
      .songlis {
        .mtable {
          width: 100%;
          border: 1px solid #d9d9d9;
          border-collapse: collapse;
          border-spacing: 0;
          table-layout: fixed;
          thead {
            tr {
              th {
                height: 38px;
                background-color: #f7f7f7;
                background-position: 0 0;
                background-repeat: repeat-x;
                vertical-align: top;
                text-align: left;
                font-weight: normal;
                font-size: 12px;
                color: #666;
                border-right: 1px solid #666;
                line-height: 38px;
                padding: 0px 10px;
              }
              .first {
                width: 59px;
              }
              .biao {
                width: 210px;
              }
              .time {
                width: 90px;
              }
              .artister {
                width: 70px;
              }
            }
          }
          tbody {
            tr {
              td {
                padding: 6px 10px;
                line-height: 18px;
                text-align: left;
                font-size: 12px;
                color: #999;
              }
              .one {
                .hd {
                  height: 18px;
                  .num {
                    float: left;
                    width: 25px;
                    margin-left: 0;
                    text-align: center;
                  }
                  .iconfont {
                    font-size: 20px;
                    margin-left: 13px;
                    color: #b3b3b3;
                  }
                  .iconfont:hover {
                    color: #666666;
                  }
                }
              }
              .music {
                padding: 10px;
                color: #333;
                a {
                  color: #333;
                  font-size: 12px;
                }
                a:hover {
                  text-decoration: underline;
                }
              }
              .timelong {
                color: #333;
                .icn {
                  margin-right: 5px;
                  margin-bottom: 3px;
                  color: #666;
                  .iconfont {
                    font-size: 15px;
                  }
                }
                .icons {
                  display: none;
                }
              }
              .artister {
                color: #333;
                cursor: pointer;
              }
              .artister:hover {
                text-decoration: underline;
              }
              .zhuan {
                color: #333;
                cursor: pointer;
              }
              .zhuan:hover {
                text-decoration: underline;
              }
            }
            tr:hover {
              .timelong .icons {
                display: block;
              }
              .timelong span {
                display: none;
              }
            }
          }
        }
      }
    }
    .m-playlist-see-more {
      width: 100%;
      height: 66px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-direction: column;
      margin-top: 30px;
      margin-bottom: -10px;
      .text {
        font-size: 13px;
        color: #333333;
      }
      .nowdow {
        display: inline-block;
        width: 120px;
        height: 30px;
        background-image: linear-gradient(90deg, #ff5a4c 0%, #ff1d12 100%);
        border-radius: 18px;
        line-height: 30px;
        font-size: 12px;
        color: #ffffff;
        text-align: center;
      }
    }
    // 评论
    .n-cmt {
      .commo {
        margin-top: 40px;
        .comtit {
          height: 33px;
          border-bottom: 2px solid #c20c0c;
          display: flex;
          justify-content: left;
          align-items: center;
          h3 {
            font-size: 20px;
            font-weight: normal;
          }
          span {
            margin-left: 20px;
            color: #666;
            font-size: 12px;
          }
        }
        .commain {
          // 评论输入框
          .iptarea {
            margin-bottom: 20px;
            display: flex;
            justify-content: left;
            align-items: center;
            margin-top: 20px;
            .head {
              width: 50px;
              height: 50px;
              margin-right: 20px;
              margin-bottom: 35px;
              img {
                width: 100%;
                height: 100%;
              }
            }
            .hflag {
              .shuqu {
                padding-right: 14px;
                textarea {
                  height: 50px;
                  display: block;
                  padding: 5px 6px 6px;
                  border: 1px solid #cdcdcd;
                  border-radius: 2px;
                  line-height: 19px;
                  box-sizing: content-box;
                  resize: none;
                  overflow: auto;
                  font-size: 12px;
                  color: #333;
                }
              }
              .combtns {
                padding: 0 10px;
                padding-top: 10px;
                .iconfont {
                  float: left;
                  margin: 0px 10px 0 0;
                  cursor: pointer;
                }
                a {
                  float: right;
                  font-size: 12px;
                  display: inline-block;
                  width: 46px;
                  height: 25px;
                  color: #fff;
                  background-color: #4391da;
                  text-align: center;
                  line-height: 25px;
                }
              }
            }
          }
          // 评论区
          .cmmts {
            position: relative;
            overflow: hidden;
            h3 {
              height: 20px;
              border-bottom: 1px solid #cfcfcf;
              font-weight: normal;
              font-size: 14px;
            }
            .acom {
              // height: 70px;
              // position: relative;
              padding: 15px 0;
              border-top: 1px solid #ccc;
              display: flex;
              justify-content: left;
              // align-items: center;
              .head {
                width: 50px;
                height: 50px;
                margin-right: 10px;
                img {
                  width: 100%;
                  height: 100%;
                }
              }
              .cntwrap {
                width: 100%;
                .usersay {
                  width: 100%;
                  overflow: hidden;
                  line-height: 20px;
                  font-size: 12px;
                  color: #333;
                  a {
                    font-size: 12px;
                    margin-right: 5px;
                    color: #0c73c2;
                  }
                  a:hover {
                    text-decoration: underline;
                  }
                  img {
                    height: 12px;
                    margin-right: 5px;
                  }
                }
                .myact {
                  margin-top: 15px;
                  text-align: right;
                  .time {
                    font-size: 12px;
                    float: left;
                    margin: 0 !important;
                    color: #999;
                  }
                  a {
                    font-size: 12px;
                    color: #999;
                  }
                  span {
                    margin: 0 8px;
                    color: #ccc;
                  }
                  .iconfont {
                    margin-right: 5px;
                    vertical-align: -2px;
                    font-size: 12px;
                    color: skyblue;
                  }
                }
              }
            }
            .hui {
              position: absolute;
              left: 0px;
              top: 0px;
              display: none;
              margin-left: 60px;
              margin-bottom: 15px;
              border: 1px solid #d9d9d9;
              border-radius: 2px;
              .iner {
                padding: 15px;
                background: #f8f8f8;
                border: 1px solid #fcfcfc;
                border-radius: 2px;
                .u-txtwrap {
                  padding-right: 14px;
                  .txthui {
                    margin: 0;
                    padding: 5px 6px 6px;
                    border: 1px solid #cdcdcd;
                    border-radius: 2px;
                    line-height: 19px;
                    box-sizing: content-box;
                    height: 20px;
                  }
                }
                .combtnss {
                  width: 530px;
                  height: 22px;
                  padding-top: 10px;
                  .iconfont {
                    float: left;
                    margin: 0px 10px 0 0;
                    cursor: pointer;
                    font-size: 20px;
                  }
                  .huifu {
                    display: inline-block;
                    width: 46px;
                    height: 25px;
                    float: right;
                    background-color: #3282ce;
                    color: #fff;
                    text-align: center;
                    line-height: 25px;
                    font-size: 12px;
                  }
                  .xz {
                    font-size: 12px;
                    float: right;
                    margin-right: 10px;
                    line-height: 25px;
                    color: #999;
                  }
                }
              }
            }
          }
          // 页数
          .j-flag {
          }
        }
      }
    }
  }
  .el-aside {
    padding: 20px 40px 40px 30px;
    .famil {
      height: 23px;
      margin-bottom: 20px;
      border-bottom: 1px solid #ccc;
      color: #333;
      font-size: 14px;
    }
    .hotots {
      margin-bottom: 25px;
      font-size: 12px;
      color: #333;
      li {
        width: 200px;
        height: 50px;
        margin-bottom: 15px;
        line-height: 24px;
        .left {
          width: 50px;
          height: 50px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .right {
          margin-left: 10px;
          p {
            width: 140px;
          }
          .fir {
            a {
              font-size: 14px;
              color: #000;
            }
          }
          .sec {
            color: #999;
            font-size: 12px;
            a {
              color: #333;
              font-size: 12px;
              margin: 0 2px 0 4px;
            }
          }
        }
      }
    }
    .likeper {
      display: flex;
      flex-wrap: wrap;
      width: 213px;
      li {
        list-style: none;
        padding: 0 0 13px 13px;
        img {
          width: 40px;
          height: 40px;
        }
      }
    }
    .moreInsl {
      margin: 20px 0;
      padding-bottom: 20px;
      .duoduan {
        height: 23px;
        margin-bottom: 20px;
        border-bottom: 1px solid #ccc;
        color: #333;
        font-size: 12px;
        font-weight: 600;
      }
      ul {
        margin-bottom: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        li {
          a {
            .iconfont {
              font-size: 45px;
              color: #c2c2c2;
            }
          }
        }
        .fir {
          a {
            width: 42px;
            height: 48px;
          }
        }
        .sec {
          width: 60px;
          height: 48px;
          margin: 0 26px 0 30px;
        }
        .thr {
          width: 42px;
          height: 48px;
        }
      }
      .last {
        font-size: 12px;
        color: #999;
      }
    }
  }
}
</style>
